package com.bamboo.framework.common.enums;

import com.baomidou.mybatisplus.extension.api.IErrorCode;

/**
 * @Author: 郭晴
 * @Date: 2018/12/15 22:07
 * @Description: 全局状态码
 */
public enum Status  implements IErrorCode {


    SUCCESS(200,"成功"),
    ERROR(5000,"失败"),
    NOT_LOGGED_IN(5001,"未登陆"),
    NEED_AUTHORITIES(5002,"权限不足"),
    LOGIN_ERROR(5003,"登陆失败"),



    PARAMETER_NULL(4001,"参数有空值"),
    DATA_DOES_NOT_EXIST(4002,"数据不存在"), DATA_DOES_EXIST(4003,"数据存在");
    private long code;
    private String name;

     Status( long code,String name) {
        this.name = name;
        this.code = code;
    }


    public static String getName(int index) {
        for (Status c : Status.values()) {
            if (c.getCode() == index) {
                return c.name;
            }
        }
        return null;
    }

    @Override
    public long getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.name;
    }
}
